package jbpmguice.instantiation;

import org.jbpm.instantiation.BeanInstantiator;

/**
 * Created by IntelliJ IDEA.
 * User: goettl
 * Date: 29.10.11
 * Time: 11:30
 * To change this template use File | Settings | File Templates.
 */
public class GuiceBeanInstantiator extends BeanInstantiator {
    String configType = "GuiceBeanInstantiator";

    @SuppressWarnings("unchecked")
    protected Object newInstance(@SuppressWarnings("rawtypes") Class clazz) {
        return GuiceConfigurationLoader.getConfigurationLoader().getInstance(clazz);
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        GuiceBeanInstantiator bean = (GuiceBeanInstantiator) o;

        if (configType != null ? !configType.equals(bean.configType) : bean.configType != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return configType != null ? configType.hashCode() : 0;
    }
}
